<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <script type="text/javascript" src="webjars/jquery/3.2.0/jquery.js"></script>
</head>
<body>
<form action="/user/adduser" method="post">
    用户名:<input type="text" name="user"></br></br>
    密码:<input type="password" name="password"></br></br>

</form>
<input id="submit" type="button" value="提交">

<script type="text/javascript">
    $('#submit').on('click', function () {
        var user = $("input[name='user']").val();
        var password = $("input[name='password']").val();
        console.info(user);
        console.info(password);
        if (!user || user == '') {
            alert("用户名不能为空");
            return;
        }
        if (!password || password == '') {
            alert("密码不能为空");
            return;
        }
        $.ajax({
            type: "post",
            url: "/user/adduser",
            contentType: "application/json",
            dataType: "json",
            data: JSON.stringify({
                "name": user,
                "password": password
            }),
            success: function (result) {

                console.info(result);

            }
        });

    });
</script>
</body>
</html>